//=============================================================================
#ifndef __CAPPSTATEMENU_H__
	#define __CAPPSTATEMENU_H__

#include "AppState.h"
#include "SDL_ttf.h"
#include "Area.h"
#include "Camera.h"
#include "Entity.h"
#include "Surface.h"
#include "Client.h"

//=============================================================================
class CAppStateMenu : public CAppState {
	private:
		static CAppStateMenu Instance;
		
	private:

		//State machine choices for menu.
		enum menu
		{
			MAINMENU_CHOICE = 0,
			JOIN_CHOICE,
			OPTIONS_CHOICE,
			CREDITS_CHOICE,
			CONTROL_CHOICE,
			NAME_CHOICE,
			PORT_CHOICE,
		};

		CAppStateMenu();

		//Various Menu boxes that will appear depending on menu state
		SDL_Surface* ControlsBox;
		SDL_Surface* OptionBox;
		SDL_Surface* menuBG;
		SDL_Surface* IPBox;
		SDL_Surface * NameBox;

		//used for animation in menu
		SDL_Surface* spell;		
		SDL_Surface* sky;		
		SDL_Rect sky1;			
		SDL_Rect sky2;			
		SDL_Rect sky3;			
		SDL_Rect fire1;			
		SDL_Rect fire2;			

		std::string optionsText;// used for fullscreen on/off text 
		bool KeyInput;			
		bool fullscreen;		//Set fullscreen on/off
		bool screenChoice;		//If screen is suppose to change
		bool writeIP;			//a bool that determines if you may write  IP or Port code in textbox.
		CItems itemInstance;
		int MAX_IP_SIZE;		//Determines how many symbols the IP string can hold. therefore determine the length of IP
		int choice;				//The variable that sets current option 
		int mainChoice;			//The MainMenu stateMachine variable, change the number in this variable to change main menu state.

		//Various fonts
		TTF_Font* IPFont;
		TTF_Font* menuChoiceFont;
		TTF_Font* mainTextfont;
		
	public:
		

		//This functions handles key actions. there are two ways to handle this. 1) on key up 2) on key down.
		void OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode);
		void OnKeyUp(SDLKey sym, SDLMod mod, Uint16 unicode);

		//These are an extension of the key action functions.
		void OnKeyIpWrite(SDLKey sym);								//This enables controls for IP box
		void OnKeyPortWrite(SDLKey sym);							//This enables controls for Port box
		void OnKeyMainMenuChoice(SDLKey sym);						//This enables controls for MainMenu
		void OnKeyOptions(SDLKey sym);								//This enables controls for Option box
		void OnKeyOptionsControls(SDLKey sym);						//This enables controls for customize keybinding Option box
		void OnKeyNameWrite(SDLKey sum);							//This enables controls for customize Items/Name Option box

		//These are an extension of the OnRender function
		void OnRenderOptions(SDL_Surface* Surf_Display);			//Render Option box
		void OnRenderJoin(SDL_Surface* Surf_Display);				//Render Join box (IP Box, Port box)
		void OnRenderMainWindow(SDL_Surface* Surf_Display);			//Render MainMenu
		void OnRenderNameChoice(SDL_Surface * Surf_Display);		//Render Item/Name customize box
		void OnRenderControls(SDL_Surface* Surf_Display);			//Render Customize keybinds box

		SDL_Surface* OnRenderSDLKey(SDLKey input);					//Writes sdlKeys to understandable text.

		void OnLoopAnimation();	//The Menu loop

	public:
		void OnActivate();		//When the Menu gamestate is being activated

		void OnDeactivate();	//When the Menu gamestate is being deactivated

		void OnLoop();			//The main menu loop, this is mostly used for animations at the moment	

		void OnRender(SDL_Surface* Surf_Display);	//Main render function in this class. every other OnRenderXX function is called in this function

	public:
		static CAppStateMenu* GetInstance();		
};

//=============================================================================

#endif
